Skip to content

Conversation

@v0y4g3r
Copy link
Contributor

@v0y4g3r v0y4g3r commented Sep 22, 2025

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

prof.gdump is a convenient features provided by jemalloc that dumps the memory profiling data every time the memory usage exceeds previous maximum value. This PR adds an HTTP endpoint to control the status of prof.gdump.

Add Support for Jemalloc Gdump Flag

  • jemalloc.rs: Introduced PROF_GDUMP constant and added functions set_gdump_active and is_gdump_active to manage the gdump flag.
  • error.rs: Added error handling for reading and updating the jemalloc gdump flag with ReadGdump and UpdateGdump errors.
  • lib.rs: Exposed is_gdump_active and set_gdump_active functions for non-Windows platforms.
  • http.rs: Added HTTP routes for checking and toggling the jemalloc gdump flag status.
  • mem_prof.rs: Implemented handlers gdump_toggle_handler and gdump_status_handler for managing gdump flag via HTTP requests.

PR Checklist

Please convert it to a draft if some of the following conditions are not met.

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.
  • API changes are backward compatible.
  • Schema or data changes are backward compatible.

@v0y4g3r v0y4g3r requested a review from a team as a code owner September 22, 2025 07:27
@github-actions github-actions bot added size/S documentation docs-not-required This change does not impact docs. labels Sep 22, 2025
Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others LGTM

@evenyag
Copy link
Contributor

evenyag commented Oct 22, 2025

Maybe we should expose a key-value API for malloc conf. So we don't have to add an API for each configuration.

v0y4g3r and others added 3 commits October 23, 2025 01:54
 ### Add Support for Jemalloc Gdump Flag

 - **`jemalloc.rs`**: Introduced `PROF_GDUMP` constant and added functions `set_gdump_active` and `is_gdump_active` to manage the gdump flag.
 - **`error.rs`**: Added error handling for reading and updating the jemalloc gdump flag with `ReadGdump` and `UpdateGdump` errors.
 - **`lib.rs`**: Exposed `is_gdump_active` and `set_gdump_active` functions for non-Windows platforms.
 - **`http.rs`**: Added HTTP routes for checking and toggling the jemalloc gdump flag status.
 - **`mem_prof.rs`**: Implemented handlers `gdump_toggle_handler` and `gdump_status_handler` for managing gdump flag via HTTP requests.

Signed-off-by: Lei, HUANG <[email protected]>
Signed-off-by: Lei, HUANG <[email protected]>
@v0y4g3r
Copy link
Contributor Author

v0y4g3r commented Oct 22, 2025

Maybe we should expose a key-value API for malloc conf. So we don't have to add an API for each configuration.

I further considered that, if we expose key-value api, we still need to

Maybe we should expose a key-value API for malloc conf. So we don't have to add an API for each configuration.

Later I read the je_mallctl docs but found that there are only a few options that can be configured at runtime (those marked as w) namely: arenas.dirty_decay_ms,arenas.muzzy_decay_ms,max_background_threads,thread.arena,prof.gdump,prof.active,prof.reset, so I decided not to expose a generic key-value API for that.

@v0y4g3r v0y4g3r enabled auto-merge October 24, 2025 01:35
@v0y4g3r v0y4g3r added this pull request to the merge queue Oct 27, 2025
Merged via the queue into GreptimeTeam:main with commit e386a36 Oct 27, 2025
52 checks passed
@v0y4g3r v0y4g3r deleted the feat/gdump branch October 27, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required This change does not impact docs. documentation size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants